package Tydzien2;
import java.io.PrintStream;
import java.util.Random;


public class Tablice {

	public static void fillArray(int[] tab, int a)
	{
		for(int i = 0; i < tab.length; ++i)
		{
			tab[i] = a;
		}
	}
	
	public static void printArray(PrintStream stream, int[] tab)
	{
		for(int i = 0; i < tab.length; ++i)
		{
			stream.print(tab[i]+" ");
		}
		stream.println("");
	}
	
	public static void fillArrayDescending(int[] tab)
	{
		for(int i = 0; i < tab.length; ++i)
		{
			tab[i] = 20-i;
		}
	}
	
	public static int[] createArray(int size)
	{
		int[] tab =  new int[size];
		fillArray(tab, 0);
		return tab;
	}
	
	public static int[] createRandomArray(int size)
	{
		int[] tab =  new int[size];
		for(int i = 0; i < size; ++i)
		{
			tab[i] = (int) (Math.random()*20);
		}
		return tab;
	}
	
	public static int[] createRandomRangeArray(int size, int range)
	{
		int[] tab =  new int[size];
		Random generator = new Random();
		for(int i = 0; i < size; ++i)
		{
			tab[i] = generator.nextInt(range);
		}
		return tab;
	}
	
	public static void bubbleSort(int[] tab)
	{
		for(int i = 0; i < tab.length; ++i)
		{
			for(int j = i+1; j < tab.length; ++j)
			{
				if(tab[i] > tab[j])
				{
					int temp = tab[i];
					tab[i] = tab[j];
					tab[j] = temp;
				}
			}
		}
	}
}
